/*
 ------------------------------------------------------------------------------
 Copyright (C) 1996-2001 Id Software, Inc.

 This file is part of the Quake source code.

 The Quake source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The Quake source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the Quake source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


//
// rect.cpp - rectangle math library
//


#include "../shared.h"


glqRect		rect_empty(0, 0, 0, 0);


/*
 ==================
 glqRect::ToBounds
 ==================
*/
void glqRect::ToBounds (glqBounds &bounds) const {

	bounds[0][0] = x1;
	bounds[0][1] = y1;
	bounds[0][2] = 0.0f;
	bounds[1][0] = x2;
	bounds[1][1] = y2;
	bounds[1][2] = 1.0f;
}

/*
 ==================
 glqRect::FromBounds
 ==================
*/
void glqRect::FromBounds (const glqBounds &bounds){

	x1 = glqMath::FloatToShort(bounds[0][0]);
	y1 = glqMath::FloatToShort(bounds[0][1]);
	x2 = glqMath::FloatToShort(bounds[1][0]);
	y2 = glqMath::FloatToShort(bounds[1][1]);
}

/*
 ==================
 glqRect::ToString

 This is just a convenience function for printing rects
 ==================
*/
const char *glqRect::ToString (void) const {

	return Str_VarArgs("%i %i %i %i", x1, y1, x2, y2);
}